package com.dog.basics.service.mtkj.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dog.basics.bean.dto.admin.mtkj.HospitalAddDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalEditDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalFromDto;
import com.dog.basics.bean.dto.admin.mtkj.StatisticsFromDto;
import com.dog.basics.bean.model.common.DogComPositioninfo;
import com.dog.basics.bean.model.mtkj.MtDeviceHospital;
import com.dog.basics.bean.model.mtkj.MtDeviceHospitalCost;
import com.dog.basics.bean.model.mtkj.MtDeviceHospitalWheelchair;
import com.dog.basics.bean.model.sys.SysUser;
import com.dog.basics.bean.vo.admin.common.DataNewVo;
import com.dog.basics.bean.vo.admin.common.DataVo;
import com.dog.basics.bean.vo.admin.mtkj.*;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.ToolUtil;
import com.dog.basics.dao.common.DogComPositioninfoMapper;
import com.dog.basics.dao.mtkj.MtDeviceHospitalCostMapper;
import com.dog.basics.dao.mtkj.MtDeviceHospitalMapper;
import com.dog.basics.dao.mtkj.MtDeviceHospitalWheelchairMapper;
import com.dog.basics.dao.mtkj.MtDeviceOrderMapper;
import com.dog.basics.dao.sys.SysUserMapper;
import com.dog.basics.security.util.SecurityUtils;
import com.dog.basics.service.mtkj.IMtDeviceHospitalService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 医院管理 服务实现类
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@Service
@AllArgsConstructor
public class MtDeviceHospitalServiceImpl extends ServiceImpl<MtDeviceHospitalMapper, MtDeviceHospital> implements IMtDeviceHospitalService {
    private final DogComPositioninfoMapper dogComPositioninfoMapper;
    private final SysUserMapper sysUserMapper;
    private final MtDeviceHospitalCostMapper mtDeviceHospitalCostMapper;
    private final MtDeviceHospitalWheelchairMapper mtDeviceHospitalWheelchairMapper;
    private final MtDeviceOrderMapper mtDeviceOrderMapper;

    /**
     * 分页的条件公用类
     *
     * @param name,mobile
     * @param userIds
     */
    public List<Long> getuserIdsWhere(String name, String mobile, List<Long> userIds) {
        List<Long> collect = sysUserMapper.selectList(Wrappers.<SysUser>lambdaQuery().like(StrUtil.isNotBlank(mobile), SysUser::getMobile, mobile).like(StrUtil.isNotBlank(name), SysUser::getUsername, name)).stream().map(e -> e.getUserId()).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(collect)) {
            userIds = collect;
        } else {
            userIds.add(-2L);
        }
        return userIds;
    }

    /**
     * @Description: 分页医院管理
     * @Param: status
     * @return: IPage<HospitalVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public IPage<HospitalVo> getPageList(PageParam page, HospitalFromDto obj) {
        Long userId = null;
        //权限判断
        if (SecurityUtils.getSysUser().getAccountType() == 2) {
            userId = SecurityUtils.getSysUser().getUserId();

        }
        // 判断所属用户ID
        List<Long> userIds = CollUtil.newArrayList();
        if (StrUtil.isNotBlank(obj.getUserName()) || StrUtil.isNotBlank(obj.getUserMobile())) {
            userIds = getuserIdsWhere(obj.getUserName(), obj.getUserMobile(), userIds);
        }
        this.page(page, new LambdaQueryWrapper<MtDeviceHospital>()
                .eq(ObjectUtil.isNotNull(userId), MtDeviceHospital::getHospitalAgentUserId, userId)
                .in(CollUtil.isNotEmpty(userIds), MtDeviceHospital::getHospitalAgentUserId, userIds)
                .like(StrUtil.isNotBlank(obj.getHospitalName()), MtDeviceHospital::getHospitalName, obj.getHospitalName())
                .like(StrUtil.isNotBlank(obj.getDetailedAddress()), MtDeviceHospital::getDetailedAddress, obj.getDetailedAddress())
                .eq(ObjectUtil.isNotNull(obj.getHospitalAgentUserId()), MtDeviceHospital::getHospitalAgentUserId, obj.getHospitalAgentUserId())
                .eq(ObjectUtil.isNotNull(obj.getProvinceId()), MtDeviceHospital::getProvinceId, obj.getProvinceId())
                .eq(ObjectUtil.isNotNull(obj.getCityId()), MtDeviceHospital::getCityId, obj.getCityId())
                .eq(ObjectUtil.isNotNull(obj.getAreaId()), MtDeviceHospital::getAreaId, obj.getAreaId())
                .orderBy(Boolean.TRUE, obj.getIsOrderByAvg(), MtDeviceHospital::getCreateTime));
        List<MtDeviceHospital> records = page.getRecords();
        page.setRecords(records.stream().map(e -> {
            HospitalVo newsVo = BeanUtil.toBean(e, HospitalVo.class);
            // 查询
            SysUser sysUser = sysUserMapper.selectById(e.getHospitalAgentUserId());
            DogComPositioninfo province = dogComPositioninfoMapper.selectById(e.getProvinceId());
            DogComPositioninfo city = dogComPositioninfoMapper.selectById(e.getCityId());
            DogComPositioninfo area = dogComPositioninfoMapper.selectById(e.getAreaId());
            newsVo.setUserName(ObjectUtil.isNotNull(sysUser) ? sysUser.getUsername() : "");
            newsVo.setUserMobile(ObjectUtil.isNotNull(sysUser) ? sysUser.getMobile() : "");
            newsVo.setProvinceName(ObjectUtil.isNotNull(province) ? province.getAreaName() : "");
            newsVo.setCityName(ObjectUtil.isNotNull(city) ? city.getAreaName() : "");
            newsVo.setAreaName(ObjectUtil.isNotNull(area) ? area.getAreaName() : "");
            return newsVo;
        }).collect(Collectors.toList()));
        return page;
    }

    /**
     * @Description: 增加医院管理
     * @Param: obj
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveObj(HospitalAddDto obj) {
        SysUser sysUser = sysUserMapper.selectById(obj.getHospitalAgentUserId());
        Validator.validateNotNull(sysUser, "代理商不存在!");
        DogComPositioninfo province = dogComPositioninfoMapper.selectById(obj.getProvinceId());
        Validator.validateNotNull(province, "省不存在!");
        DogComPositioninfo city = dogComPositioninfoMapper.selectById(obj.getCityId());
        Validator.validateNotNull(city, "市不存在!");
        DogComPositioninfo area = dogComPositioninfoMapper.selectById(obj.getAreaId());
        Validator.validateNotNull(area, "区不存在!");
        MtDeviceHospital dogNews = new MtDeviceHospital();
        BeanUtil.copyProperties(obj, dogNews);
        dogNews.setCreateTime(DateUtil.currentSeconds());
        dogNews.setCreateBy(SecurityUtils.getSysUser().getUserId());
        Validator.validateTrue(this.save(dogNews), "数据保存失败!");
        return Boolean.TRUE;
    }

    /**
     * @Description: 修改医院管理
     * @Param: obj
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean editObj(HospitalEditDto obj) {
        MtDeviceHospital dogNews = this.getById(obj.getId());
        Validator.validateNotNull(dogNews, "无此数据!");
        SysUser sysUser = sysUserMapper.selectById(obj.getHospitalAgentUserId());
        Validator.validateNotNull(sysUser, "代理商不存在!");
        DogComPositioninfo province = dogComPositioninfoMapper.selectById(obj.getProvinceId());
        Validator.validateNotNull(province, "省不存在!");
        DogComPositioninfo city = dogComPositioninfoMapper.selectById(obj.getCityId());
        Validator.validateNotNull(city, "市不存在!");
        DogComPositioninfo area = dogComPositioninfoMapper.selectById(obj.getAreaId());
        Validator.validateNotNull(area, "区不存在!");
        BeanUtil.copyProperties(obj, dogNews);
        dogNews.setUpdateTime(DateUtil.currentSeconds());
        dogNews.setUpdateBy(SecurityUtils.getSysUser().getUserId());
        Validator.validateTrue(this.updateById(dogNews), "修改数据失败!");
        return Boolean.TRUE;
    }

    /**
     * @Description: 删除医院管理
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteObj(Long id) {
        MtDeviceHospital dogNews = this.getById(id);
        Validator.validateNotNull(dogNews, "无此数据!");
        List<MtDeviceHospitalCost> mtDeviceHospitalCostList = mtDeviceHospitalCostMapper.selectList(Wrappers.<MtDeviceHospitalCost>lambdaQuery().eq(MtDeviceHospitalCost::getDeviceHospitalId, id));
        Validator.validateFalse(CollUtil.isNotEmpty(mtDeviceHospitalCostList), "医院下有医院费用无法删除!");
        List<MtDeviceHospitalWheelchair> mtDeviceHospitalWheelchairList = mtDeviceHospitalWheelchairMapper.selectList(Wrappers.<MtDeviceHospitalWheelchair>lambdaQuery().eq(MtDeviceHospitalWheelchair::getHospitalId, id));
        Validator.validateFalse(CollUtil.isNotEmpty(mtDeviceHospitalWheelchairList), "医院下有轮椅无法删除!");
        Validator.validateTrue(this.removeById(id), "数据删除失败!");
        return Boolean.TRUE;
    }

    /**
     * @Description: 首页展示
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public IndexVo getIndexVo(Integer wheeType) {
        //权限判断
        Long userId = null;
        //权限判断
        if (Validator.equal(SecurityUtils.getSysUser().getAccountType(), 2)) {
            // 查询属于自己的订单
            userId = SecurityUtils.getSysUser().getUserId();
        }
        List<DataNewVo> weekSr = CollUtil.newArrayList();
        List<DataNewVo> monthSr = CollUtil.newArrayList();
        List<DataVo> weekOrder = CollUtil.newArrayList();
        List<DataVo> monthOrder = CollUtil.newArrayList();
        //当天开始时间
        Long startTime = ToolUtil.dateSecond(DateUtil.beginOfDay(DateUtil.date()));
        //当天结束时间
        Long endTime = ToolUtil.dateSecond(DateUtil.endOfDay(DateUtil.date()));
        //当月开始时间
        Long startMonthTime = ToolUtil.dateSecond(DateUtil.beginOfMonth(DateUtil.date()));
        //当月结束时间
        Long endMonthTime = ToolUtil.dateSecond(DateUtil.endOfMonth(DateUtil.date()));
        IndexVo indexVo = new IndexVo();
        indexVo.setOrderNum(mtDeviceOrderMapper.getOrderCount(userId, null, null, wheeType));
        indexVo.setDayMoney(mtDeviceOrderMapper.getMoney(userId, startTime, endTime, wheeType));
        indexVo.setMonthMoney(mtDeviceOrderMapper.getMoney(userId, startMonthTime, endMonthTime, wheeType));
        indexVo.setMoney(mtDeviceOrderMapper.getMoney(userId, null, null, wheeType));
        DateTime time = DateUtil.offsetDay(DateUtil.date(), -6);
        //近一周的
        for (int i = 0; i < 7; i++) {
            DataNewVo dataNewVo = new DataNewVo();
            DataVo dataVo = new DataVo();
            //获取当前月开始时间结束时间
            Long startTime1 = ToolUtil.dateSecond(DateUtil.beginOfDay(DateUtil.offsetDay(time, i)));
            String dateInfo = DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(time, i)), DatePattern.NORM_DATE_PATTERN);
            Long endTime1 = ToolUtil.dateSecond(DateUtil.endOfDay(DateUtil.offsetDay(time, i)));
            //金额
            BigDecimal money = mtDeviceOrderMapper.getMoney(userId, startTime1, endTime1, wheeType);
            //订单数
            Integer num = mtDeviceOrderMapper.getOrderCount(userId, startTime1, endTime1, wheeType);
            dataNewVo.setTime(dateInfo);
            dataNewVo.setMoney(money);
            dataVo.setTime(dateInfo);
            dataVo.setNum(num);
            weekSr.add(dataNewVo);
            weekOrder.add(dataVo);
        }
        //近一个月的
        DateTime monthTime = DateUtil.offsetDay(DateUtil.date(), -29);
        for (int i = 0; i < 30; i++) {
            DataNewVo dataNewVo = new DataNewVo();
            DataVo dataVo = new DataVo();
            //获取当前月开始时间结束时间
            Long startTime1 = ToolUtil.dateSecond(DateUtil.beginOfDay(DateUtil.offsetDay(monthTime, i)));
            String dateInfo = DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(monthTime, i)), DatePattern.NORM_DATE_PATTERN);
            Long endTime1 = ToolUtil.dateSecond(DateUtil.endOfDay(DateUtil.offsetDay(monthTime, i)));
            //金额
            BigDecimal money = mtDeviceOrderMapper.getMoney(userId, startTime1, endTime1, wheeType);
            //订单数
            Integer num = mtDeviceOrderMapper.getOrderCount(userId, startTime1, endTime1, wheeType);
            dataNewVo.setTime(dateInfo);
            dataNewVo.setMoney(money);
            dataVo.setTime(dateInfo);
            dataVo.setNum(num);
            monthSr.add(dataNewVo);
            monthOrder.add(dataVo);
        }
        indexVo.setWeekSr(weekSr);
        indexVo.setMonthSr(monthSr);
        indexVo.setWeekOrder(weekOrder);
        indexVo.setMonthOrder(monthOrder);
        return indexVo;
    }

    /**
     * @Description: 轮椅日报列表
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public List<StatisticsDayVo> getDayList(StatisticsFromDto obj) {
        //权限判断
        List<Long> ids = CollUtil.newArrayList();
        if (SecurityUtils.getSysUser().getAccountType() == 2) {
            ids = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().eq(MtDeviceHospital::getHospitalAgentUserId, SecurityUtils.getSysUser().getUserId())).stream().map(e -> e.getId()).collect(Collectors.toList());
            if (CollUtil.isEmpty(ids)) {
                ids.add(-2L);
            }
        }
        List<Long> hospitalIds = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().in(CollUtil.isNotEmpty(ids), MtDeviceHospital::getId, ids).eq(ObjectUtil.isNotNull(obj.getProvinceId()), MtDeviceHospital::getProvinceId, obj.getProvinceId()).eq(ObjectUtil.isNotNull(obj.getCityId()), MtDeviceHospital::getCityId, obj.getCityId()).eq(ObjectUtil.isNotNull(obj.getAreaId()), MtDeviceHospital::getAreaId, obj.getAreaId()).like(StrUtil.isNotBlank(obj.getHospitalName()), MtDeviceHospital::getHospitalName, obj.getHospitalName())).stream().map(e -> e.getId()).collect(Collectors.toList());
        if (CollUtil.isEmpty(hospitalIds)) {
            hospitalIds.add(-2L);
        }
        List<StatisticsDayVo> time = this.baseMapper.getTimeList(obj.getNum(), obj.getStartTime(), obj.getEndTime(), hospitalIds, obj.getWheeType());
        time.forEach(e -> {
            e.setId(IdWorker.getId());
            Long startTime = ToolUtil.dateSecond(DateUtil.beginOfDay(DateUtil.parse(e.getTime())));
            Long endTime = ToolUtil.dateSecond(DateUtil.endOfDay(DateUtil.parse(e.getTime())));
            List<StatisticsDayChildrenVo> list = this.baseMapper.getChildrenList(startTime, endTime, hospitalIds, obj.getWheeType());
            list.forEach(f -> {
                f.setId(IdWorker.getId());
            });
            e.setChildren(list);
        });
        return time;
    }

    /**
     * @Description: 轮椅日报列表导出
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public List<StatisticsExportDayChildrenVo> getExportDayList(StatisticsFromDto obj) {
        //权限判断
        List<Long> ids = CollUtil.newArrayList();
        if (SecurityUtils.getSysUser().getAccountType() == 2) {
            ids = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().eq(MtDeviceHospital::getHospitalAgentUserId, SecurityUtils.getSysUser().getUserId())).stream().map(e -> e.getId()).collect(Collectors.toList());
            if (CollUtil.isEmpty(ids)) {
                ids.add(-2L);
            }
        }
        List<StatisticsExportDayChildrenVo> list = CollUtil.newArrayList();
        List<Long> hospitalIds = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().in(CollUtil.isNotEmpty(ids), MtDeviceHospital::getId, ids).eq(ObjectUtil.isNotNull(obj.getProvinceId()), MtDeviceHospital::getProvinceId, obj.getProvinceId()).eq(ObjectUtil.isNotNull(obj.getCityId()), MtDeviceHospital::getCityId, obj.getCityId()).eq(ObjectUtil.isNotNull(obj.getAreaId()), MtDeviceHospital::getAreaId, obj.getAreaId()).like(StrUtil.isNotBlank(obj.getHospitalName()), MtDeviceHospital::getHospitalName, obj.getHospitalName())).stream().map(e -> e.getId()).collect(Collectors.toList());
        if (CollUtil.isEmpty(hospitalIds)) {
            hospitalIds.add(-2L);
        }
        List<StatisticsDayVo> time = this.baseMapper.getTimeList(obj.getNum(), obj.getStartTime(), obj.getEndTime(), hospitalIds, obj.getWheeType());
        time.forEach(e -> {
            StatisticsExportDayChildrenVo statisticsDayChildrenVo = BeanUtil.copyProperties(e, StatisticsExportDayChildrenVo.class);
            list.add(statisticsDayChildrenVo);
            Long startTime = ToolUtil.dateSecond(DateUtil.beginOfDay(DateUtil.parse(e.getTime())));
            Long endTime = ToolUtil.dateSecond(DateUtil.endOfDay(DateUtil.parse(e.getTime())));
            List<StatisticsExportDayChildrenVo> childrenList = this.baseMapper.getExporChildrenList(startTime, endTime, hospitalIds, obj.getWheeType());
            if (CollUtil.isNotEmpty(childrenList)) {
                list.addAll(childrenList);
            }
        });
        return list;
    }

    /**
     * @Description: 轮椅月报列表
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public List<StatisticsDayVo> getMonthList(StatisticsFromDto obj) {
        //权限判断
        List<Long> ids = CollUtil.newArrayList();
        if (SecurityUtils.getSysUser().getAccountType() == 2) {
            ids = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().eq(MtDeviceHospital::getHospitalAgentUserId, SecurityUtils.getSysUser().getUserId())).stream().map(e -> e.getId()).collect(Collectors.toList());
            if (CollUtil.isEmpty(ids)) {
                ids.add(-2L);
            }
        }

        List<Long> hospitalIds = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().in(CollUtil.isNotEmpty(ids), MtDeviceHospital::getId, ids).eq(ObjectUtil.isNotNull(obj.getProvinceId()), MtDeviceHospital::getProvinceId, obj.getProvinceId()).eq(ObjectUtil.isNotNull(obj.getCityId()), MtDeviceHospital::getCityId, obj.getCityId()).eq(ObjectUtil.isNotNull(obj.getAreaId()), MtDeviceHospital::getAreaId, obj.getAreaId()).like(StrUtil.isNotBlank(obj.getHospitalName()), MtDeviceHospital::getHospitalName, obj.getHospitalName())).stream().map(e -> e.getId()).collect(Collectors.toList());
        if (CollUtil.isEmpty(hospitalIds)) {
            hospitalIds.add(-2L);
        }
        List<StatisticsDayVo> time = this.baseMapper.getMonthList(obj.getNum(), obj.getStartTime(), obj.getEndTime(), hospitalIds,obj.getWheeType());
        time.forEach(e -> {
            e.setId(IdWorker.getId());
            Long startTime = ToolUtil.dateSecond(DateUtil.beginOfMonth(DateUtil.parse(e.getTimeTwo())));
            Long endTime = ToolUtil.dateSecond(DateUtil.endOfMonth(DateUtil.parse(e.getTimeTwo())));
            List<StatisticsDayChildrenVo> list = this.baseMapper.getChildrenList(startTime, endTime, hospitalIds, obj.getWheeType());
            list.forEach(f -> {
                f.setId(IdWorker.getId());
            });
            e.setChildren(list);
        });
        return time;
    }

    /**
     * @Description: 轮椅月报列表导出
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @Override
    public List<StatisticsExportDayChildrenVo> getExportMonthList(StatisticsFromDto obj) {
        //权限判断
        List<Long> ids = CollUtil.newArrayList();
        if (SecurityUtils.getSysUser().getAccountType() == 2) {
            ids = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().eq(MtDeviceHospital::getHospitalAgentUserId, SecurityUtils.getSysUser().getUserId())).stream().map(e -> e.getId()).collect(Collectors.toList());
            if (CollUtil.isEmpty(ids)) {
                ids.add(-2L);
            }
        }
        List<Long> hospitalIds = this.list(Wrappers.<MtDeviceHospital>lambdaQuery().in(CollUtil.isNotEmpty(ids), MtDeviceHospital::getId, ids).eq(ObjectUtil.isNotNull(obj.getProvinceId()), MtDeviceHospital::getProvinceId, obj.getProvinceId()).eq(ObjectUtil.isNotNull(obj.getCityId()), MtDeviceHospital::getCityId, obj.getCityId()).eq(ObjectUtil.isNotNull(obj.getAreaId()), MtDeviceHospital::getAreaId, obj.getAreaId()).like(StrUtil.isNotBlank(obj.getHospitalName()), MtDeviceHospital::getHospitalName, obj.getHospitalName())).stream().map(e -> e.getId()).collect(Collectors.toList());
        if (CollUtil.isEmpty(hospitalIds)) {
            hospitalIds.add(-2L);
        }
        List<StatisticsDayVo> time = this.baseMapper.getMonthList(obj.getNum(), obj.getStartTime(), obj.getEndTime(), hospitalIds,obj.getWheeType());
        List<StatisticsExportDayChildrenVo> list = CollUtil.newArrayList();
        time.forEach(e -> {
            StatisticsExportDayChildrenVo statisticsDayChildrenVo = BeanUtil.copyProperties(e, StatisticsExportDayChildrenVo.class);
            list.add(statisticsDayChildrenVo);
            Long startTime = ToolUtil.dateSecond(DateUtil.beginOfMonth(DateUtil.parse(e.getTimeTwo())));
            Long endTime = ToolUtil.dateSecond(DateUtil.endOfMonth(DateUtil.parse(e.getTimeTwo())));
            List<StatisticsExportDayChildrenVo> childrenList = this.baseMapper.getExporChildrenList(startTime, endTime, hospitalIds, obj.getWheeType());
            if (CollUtil.isNotEmpty(childrenList)) {
                list.addAll(childrenList);
            }
        });
        return list;
    }
}
